<!-- 售后订单详情 -->
<template>
	<view class="page">
		<u-navbar :isFixed="true" title="立即评价" :borderBottom="false"></u-navbar>
		<view class="wrap">
			<view class="flex_align goods">
				<image class="goodsImg" :src="detail.goods_info.image"></image>
				<view style="flex:1;">
					<view class="goodsName clamp2">{{detail.goods_info.title}}</view>
					<view class="price">￥{{detail.goods_info.money}}/{{detail.goods_info.unit}}</view>
				</view>
			</view>
		</view>
		<view class="evaluate">
			<view class="textarealine">
				<view class="linetext">这次的买苗体验您还满意吗？</view>
				<view class="flex_align">
					评分　　<u-rate v-model="level" active-color="#FFA811" inactive-color="#E1E1E1" gutter="15" size="40"></u-rate>
				</view>
			</view>
			<view class="textarealine" style="border-top: 1rpx solid #eeeeee;">
				<view class="textareabox">
					<u-input v-model="content" type="textarea" :border="false" placeholder="评价一下你这次买苗的体验吧~"
						placeholderStyle="color:#B9B9B9" class="textarea_content" maxlength="80" :clearable="false" />
					<text>{{content.length}}/80</text>
				</view>
			</view>
			<view class="imgboxline">
				<view class="photos">
					<view class="photobox">
						<u-upload ref="upload" max-size="12328959" :action="action" width="210" height="210" max-count="9"  @on-remove="removeimg" @on-uploaded="uploaded"></u-upload>
					</view>
				</view>
			</view>
		</view>
		<view class="submitbox">
			<view class="submitbtn" @click="submit">确认发布</view>
		</view>
	</view>
</template>

<script>
	var _this,shak;
	export default {
		data() {
			return {
				action:"",
				content:"",
				level:0,
				detail:{},
				images:[]
			}
		},
		onLoad(options) {
			_this = this
			_this.action = _this.$api.getbase() + 'fileupload'
			_this.id=options.id
			_this.getdata()
		},
		methods: {
			// 获取数据
			getdata() {
				_this.$api.get("orderdetails", {tab_type:1,order_id:_this.id}).then(data => {
					_this.detail = data
				});
			},
			// 防抖点击
			click_shake(fn){
				if(!_this.shake){
					fn && typeof fn === 'function' && fn()
					_this.shake=true
					setTimeout(function(){
						_this.shake=false
					},500)
				}
			},
			// 删除图片
			removeimg(e) {
				_this.images.splice(e, 1)
			},
			// 上传成功
			uploaded(e) {
				_this.images = []
				e.forEach((item,index) => {
					if(item.response){
						if(item.response.code==1){
							_this.images.push(item.response.data.url)
							
						}else{
							_this.$refs['upload'].remove(index)
						}
					}	
				})
			},
			//提交回复按钮
			submit(){
				_this.click_shake(function(){
					if(_this.level<1){
						uni.showToast({
							title:"请评分",
							icon:"none"
						})
					}else{
						_this.$api.post("savecomment", {
							select_type:2,
							other_type:1,
							type_id: _this.id,
							level: _this.level,
							images: _this.images,
							contents: _this.content,
							
						}).then(data => {
							wx.showToast({
								title: "评价成功"
							})
							setTimeout(function(){
								uni.reLaunch({
									url:"/pages/personal/personal"
								})
							},1000);
						});
					}
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.page{
		background-color: #F8F8F8;
		min-height: 100vh;
	}
	.wrap{
		background-color: #FFFFFF;
		padding:24rpx 30rpx;
		border-bottom: 20rpx solid #F8F8F8;
		.goodsImg{
			width: 180rpx;
			height: 180rpx;
			border-radius: 16rpx;
			background-color: #EEEEEE;
			margin-right: 20rpx;
		}
		.goodsName{    
			font-size: 28rpx;
			color: #333333;
			line-height: 36rpx;
			height: 72rpx;
		}
		.price{
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Medium;
			font-weight: 500;
			color: #f73f3f;
			margin:8rpx 0 14rpx;
		}
		.sku{
			font-size: 24rpx;
			font-family: PingFang SC, PingFang SC-Regular;
			font-weight: 400;
			color: #999999;
		}
	}
	.evaluate{
		padding:10rpx 30rpx;
		background-color: #FFFFFF;
		margin-bottom: 150rpx;
	}
	.textarealine {
		display: flex;
		flex-direction: column;
		padding: 20rpx 0;
	
		.linetext {
			color: #222222;
			font-size: 30rpx;
			margin-bottom: 20rpx;
			text {
				color: #FF0000;
			}
		}
	
		.textareabox {
			border-radius: 10rpx;
			display: flex;
			flex-direction: column;
			height: 200rpx;
			text {
				font-weight: normal;
				color: #999999;
				font-size: 20rpx;
				text-align: right;
				margin-top: 20rpx;
			}
		}
	}
	.imgboxline {
		display: flex;
		flex-direction: column;
	
		.imgboxtitle {
			margin-top: 43rpx;
			color: #222222;
			font-size: 30rpx;
			font-weight: bold;
	
			._xing {
				color: #FF0000;
			}
	
			._number {
				margin-left: 10rpx;
				color: #999999;
				font-size: 28rpx;
			}
		}
	
		.imgboxmetion {
			margin-top: 26rpx;
			color: #BEBEBE;
			font-size: 24rpx;
		}
	
		.photos {
			display: flex;
			flex-direction: column;
			margin-top: 27rpx;
	
			.photobox {
				margin-top: 10rpx;
	
				.video {
					width: 100%;
					height: 410rpx;
					border-radius: 5rpx;
				}
	
				.imgupdata {
					width: 100%;
					height: 410rpx;
					border: 2rpx solid #C1C1C1;
					border-radius: 4rpx;
					text-align: center;
	
					image {
						width: 66rpx;
						height: auto;
						margin: 150rpx auto 40rpx;
					}
	
					.text {
						width: 100%;
						text-align: center;
						font-size: 30rpx;
						color: #999999;
					}
				}
			}
		}
	}
	.submitbox {
		padding: 39rpx 0 calc(env(safe-area-inset-bottom) + 39rpx) 0;
		padding: 39rpx 0;
		display: flex;
		align-items: center;
		justify-content: center;
		background: #fff;
		width: 100%;
		position: fixed;
		bottom: 0;
		z-index: 99;
	
		.submitbtn {
			width: 680rpx;
			height: 90rpx;
			border-radius: 45rpx;
			background: linear-gradient(86deg, #38BE8C, #05ADBB);
			text-align: center;
			line-height: 90rpx;
			color: #fff;
			font-size: 34rpx;
			font-weight: bold;
		}
	}
</style>
